<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('接口调用日志')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-task_call_log-edit" th:object="${testerTaskCallLog}">
            <h4 class="form-header h4">接口调用日志</h4>
            <div class="select-list">
                <ul>
                    <li>
                        <label>接口描述：</label>
                        <input type="text" name="interfaceDesc" id="interfaceDesc"/>
                    </li>
                    <li>
                        <label>返回状态：</label>
                        <select name="status" id="status">
                            <option value="">所有</option>
                            <option value="success">success</option>
                            <option value="fault">fault</option>
                        </select>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="doSearch()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </ul>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "tester/task_call_log";

        function submitHandler() {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);//关闭当前页
        }

        function doSearch(){
            var taskCallLogId = [[${testerTaskCallLog.taskCallLogId}]];
            var interfaceDesc = $("#interfaceDesc").val();
            var status = $("#status").val();
            $.get(prefix+"/search?taskCallLogId="+taskCallLogId+"&interfaceDesc="+interfaceDesc+"&status="+status,function(data,status){
                testerInterfaceCallLogList = data.data == null ? [] : data.data.testerInterfaceCallLogList;
                initTable(testerInterfaceCallLogList);
            });
        }

        $(function() {
            var data = [[${testerTaskCallLog.testerInterfaceCallLogList}]];
            initTable(data);
        });

        function initTable(rowsData){
            $.table.destroy();
            var options = {
                data: rowsData,
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [
                    {
                        field: 'index',
                        align: 'center',
                        title: "序号",
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    },
                    {
                        field: 'interfaceId',
                        align: 'center',
                        title: '接口id',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'interfaceDesc',
                        align: 'center',
                        title: '接口描述',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'status',
                        align: 'center',
                        title: '返回状态',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'response',
                        align: 'center',
                        title: '返回结果',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'responseHeaders',
                        align: 'center',
                        title: '返回headers',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'judgeExpression',
                        align: 'center',
                        title: '判定表达式',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'httpMethod',
                        align: 'center',
                        title: 'http方式',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'finalUrl',
                        align: 'center',
                        title: '实际url',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'queryParam',
                        align: 'center',
                        title: '实际query参数',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'bodyParam',
                        align: 'center',
                        title: '实际body参数',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'headers',
                        align: 'center',
                        title: 'headers',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'contentType',
                        align: 'center',
                        title: 'contentType',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'exception',
                        align: 'center',
                        title: 'exception',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner' align='left'>"+value+"</div>";
                            return html;
                        }
                    },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '创建时间',
                        formatter: function(value, row, index) {
                            var html = "<div class='th-inner'>"+value+"</div>";
                            return html;
                        }
                    }]
            };
            $.table.init(options);
        }

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();

            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    taskCallLogId: "",

                    interfaceId: "",

                    interfaceDesc: "",

                    httpMethod: "",

                    finalUrl: "",

                    bodyParam: "",

                    headers: "",

                    contentType: "",

                    status: "",

                    judgeExpression: "",

                    response: "",

                    createTime: ""

        	    }
            });
        }
    </script>
</body>
</html>
